package wdt_qf.job;

import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import wdt_qf.dao.ZxyNeedauditingretailsbillidDao;
import wdt_qf.entity.ZxyNeedauditingretailsbillid;
import wdt_qf.entity.qf.common.ResultData;
import wdt_qf.service.QfRetailsBillService;

import javax.annotation.Resource;
import java.util.List;

@Component
@EnableScheduling
@EnableAsync
@Slf4j
public class AuditingJob {


    @Resource
    private QfRetailsBillService retailsBillService;
    @Resource
    private ZxyNeedauditingretailsbillidDao zxyNeedauditingretailsbillidDao;

    @Scheduled(fixedDelay = 20000)  //间隔1秒1000
    public void uploadStocks() {
        //自动过账
        List<ZxyNeedauditingretailsbillid> needAuditingBills = zxyNeedauditingretailsbillidDao.getNeedAuditingBill();
        for (ZxyNeedauditingretailsbillid zxyNeedauditingretailsbillid : needAuditingBills) {
            ResultData httpRequestRes = retailsBillService.auditingRetailBillByBillId(zxyNeedauditingretailsbillid.getRetailBillId());
            log.info("零售单过账返回"+ JSON.toJSONString(httpRequestRes));
        }
    }

}
